<!-- 隐私(添加我的方式，黑名单) -->
<template>
  <div id="Privacy">
    <Head BackType1="1" title="隐私"></Head>
    <div id="PrivacyMain">
      <van-cell-group>
        <van-switch-cell @input="onInput" v-model="checked" title="加我为好友时需要验证" />
      </van-cell-group>
      <div class="PrivacyList">
        <div class="InstallBox BoxActive" v-for="(Title,index) in Titles" :key="index" @click="GotoDetails(index)">
          <div class="InstallTitle">{{Title}}</div>
          <img src="@/assets/img/ArrowRight.png" alt="">
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import Head from '../components/Head'
  import {CellGroup, SwitchCell } from 'vant';
  export default {
    data(){
      return{
        checked:false,
        Titles:['添加我的方式','黑名单',]
      }
    },
    components:{
      Head,
      [CellGroup.name]:CellGroup,
      [SwitchCell.name]:SwitchCell,
    },
    mounted(){
      /**
      * 新消息通知设置
      * type:10 加我是否需要验证
      * value:1是 0否
      */
      this.$get(urlConfig.getConfig)
        .then(res => {
        console.log(res);
        if(res.data.length !=0){
          for(var i=0; i<res.data.length; i++ ){
            if(res.data[i].type ==10){
              if(res.data[i].value ==0){
                this.checked = false
              }else{
                this.checked = true
              }
            }
          }
        }else{
        }
      }) 
    },
    methods:{
      onInput(){
        var valueText =''
        console.log(this.checked)
        if(this.checked==true){
          valueText = 1
        }else{
          valueText = 0
        }
        /**
        *  新消息通知设置
        * type:1 新消息通知, 2 声音, 3 振动 ，4 通过账号寻找我， 5 通过群聊加我，6 通过名片加我，7 字体大小，8 聊天背景，9 一件清除聊天记录 ，10 加我是否需要验证
        * value:1是 0否
        */
        var configtext={
          type:parseInt(10),
          value:parseInt(valueText),
        }
        console.log(configtext)
        this.$post(urlConfig.config,configtext)
          .then(res => {
          console.log(res);
        })
      },
      GotoDetails(index){
        if(index==0){
          this.$router.push('/AddMyWay')
        }else{
          this.$router.push('/Blacklist')
        }
      }
    },
  }
</script>

<style scoped lang="less">
  #Privacy{
    #PrivacyMain{
      position: fixed;
      top: 98px;
      left: 0;
      width: 100%;
      .van-cell{
        font-size: 32px;
      }
      .PrivacyList{
        font-size: 32px;
        margin-top: 20px;
        .InstallBox{
          margin-top: 10px;
          height: 90px;
          padding-left: 30px;
          background: #fff;
          border-bottom: 1px solid #e8e8e8;
          display: flex;
          flex-direction: row;
          align-items: center;
          justify-content: space-between;
          img{
            width: 14px;
            height: 22px;
            margin-right: 30px;
          }
        }
      }
    }
  }
</style>
